package thread;

public class Demo11 {
    private static int result = 0;

    public static void main(String[] args) throws InterruptedException {
        //让这个线程从 1 + 2 + 3 + ... + 1000
        //主线程中打印这个结果
        Thread t = new Thread(() -> {
            int sum = 0;
            for(int i = 0; i <= 1000; i++) {
                sum += i;
            }
            //在主线程打印
            result = sum;
        });
        t.start();

        t.join();

        System.out.println(result);
    }
}
